﻿using DeskInterfaceBLL;
using HeyPiPi_Desk.Base;
using IDeskServiceBLL;
using MaterialDesignThemes.Wpf;
using Microsoft.Practices.Prism.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace HeyPiPi_Desk.DomainViewModel
{
    public  class AddNewVipLevelDialogViewModel:BaseNotification
    {
        #region 字段/属性
        private readonly IShop_VipLevelBLL shop_VipLevelBLL = new Shop_VipLevelBLL();

        private string _levelName;

        /// <summary>
        /// 等级名称
        /// </summary>
        public string LevelName
        {
            get { return _levelName; }
            set { _levelName = value; this.RaisePropertyChanged(() => this.LevelName); }
        }

        private string _serviceDiscount;

        /// <summary>
        /// 商品折扣率
        /// </summary>
        public string ServiceDiscount
        {
            get { return _serviceDiscount; }
            set { _serviceDiscount = value; this.RaisePropertyChanged(() => this.ServiceDiscount); }
        }

        private string _sort;

        /// <summary>
        /// 排序
        /// </summary>
        public string Sort
        {
            get { return _sort; }
            set { _sort = value; this.RaisePropertyChanged(() => this.Sort); }
        }

        /// <summary>
        /// 保存命令
        /// </summary>
        public DelegateCommand Save_Cmd { get; set; }

        private string _productDiscount;
        /// <summary>
        /// 商品折扣率
        /// </summary>
        public string ProductDiscount
        {
            get { return _productDiscount; }
            set { _productDiscount = value; this.RaisePropertyChanged(() => this.ProductDiscount); }
        }

        /// <summary>
        /// 关闭命令
        /// </summary>
        public DelegateCommand Close_Cmd { get; set; }

        #endregion

        #region 私有方法
        private void _initFunc()
        {
            this.Close_Cmd = new DelegateCommand(() =>
            {
                DialogHost.CloseDialogCommand.Execute(null, null);
            });

            this.Save_Cmd = new DelegateCommand(() =>
            {
   
                this.shop_VipLevelBLL.InsertNewLevel(null, out this.error);
                if (ValidateError())
                {
                    // 验证正确之后的操作
                    
                }
                else
                {
                    // 验证失败之后的操作
                }

                // todo:保存命令
            });
        }

        #endregion

        #region 共有方法
        public AddNewVipLevelDialogViewModel()
        {
            this._initFunc();
        }

        #endregion
    }
}
